package com.it.system.adservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.it.system.adservice.entity.PromotionAd;
import com.it.system.adservice.mapper.PromotionAdMapper;
import com.it.system.adservice.service.PromotionAdService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PromotionAdServiceImpl extends ServiceImpl<PromotionAdMapper, PromotionAd> implements PromotionAdService {
    /**
     * 通过区域id查询广告列表
     *
     * @param sid
     * @return
     */
    @Resource
    private PromotionAdMapper promotionAdMapper;
    // 注释掉@Cacheable注解，避免使用Redis缓存
    // @Cacheable(cacheNames = "ad",key ="T(String).valueOf(#sid)" )

    /**
     * 通过区域id查询广告列表
     *
     * @param sid
     * @return
     */
    @Override
    public List<PromotionAd> getAdsBySpaceId(Integer sid) {
        List<PromotionAd> promotionAds = promotionAdMapper.selectList(
                new QueryWrapper<PromotionAd>
                        ().lambda().eq(PromotionAd::getSpaceId,sid));
        return promotionAds;
    }
}
